package eos.dom;

public class Card {

	private CardId id;
	private CardType type;

	public Card(CardId i){
		id = i;
		if(i == CardId.COPPER ||i == CardId.GOLD ||i == CardId.SILVER ||i == CardId.POTION){
			type = CardType.TREASURE;

		}else if(i == CardId.ESTATE ||i == CardId.DUCHY ||i == CardId.PROVINCE ||i == CardId.GARDENS){
			type = CardType.VICTORY;

		}else if(i == CardId.BUREAUCRAT ||i == CardId.MILITIA ||i == CardId.SPY 
				|| i == CardId.THIEF || i == CardId.WITCH){
			type = CardType.ACTION_ATTACK;

		}else if(i == CardId.CURSE){
			type = CardType.CURSE;

		}else{
			type = CardType.ACTION;
		}
	}

	public boolean isAttack(){
		return type == CardType.ACTION_ATTACK;
	}




	public CardId getId() {
		return id;
	}

	public void setId(CardId id) {
		this.id = id;
	}

	public CardType getType() {
		return type;
	}

	public void setType(CardType type) {
		this.type = type;
	}

	public int getPoints() {
		int p = 0;
		if(type == CardType.VICTORY || type == CardType.CURSE){
			switch(id){
			case ESTATE:
				p=1;
				break;
			case DUCHY:
				p=3;
				break;
			case PROVINCE:
				p=6;
				break;
			case CURSE:
				p=-1;
				break;
			}
		}
		return p;
	}
	
	@Override
	public boolean equals(Object o) {
		if (o instanceof Card) {
			Card card = (Card) o;
			return card.getId() == this.id;
		}
		return false;
	}

}

enum CardType { ACTION, TREASURE, VICTORY, CURSE, ACTION_ATTACK, ACTION_VICTORY, TREASURE_VICTORY }
